package dt.board.notice;

import com.opensymphony.xwork2.ActionSupport;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder; 

import java.util.*;
import java.io.Reader;
import java.io.IOException; 

import org.apache.struts2.interceptor.SessionAware;


public class noticeWriteAction extends ActionSupport implements SessionAware{
	private Map session;
	public static Reader reader; 
	public static SqlMapClient sqlMapper; 
	
	private noticeBoardVO paramClass; 
	private noticeBoardVO resultClass; 
	
	private int currentPage; 
	
	private int no; 
	private String subject; 
	private String password;
	private String content; 
	
	private int BoardFlag = 1;
	
	Calendar today = Calendar.getInstance();
	
	
	public noticeWriteAction() throws IOException{
		
		reader = Resources.getResourceAsReader("sqlMapConfig.xml");
		sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader); 
		
		
		reader.close(); 
		
	}
	
	public String form() throws Exception{
		return SUCCESS; 
	}
	
	// 게시판 쓰기 액션 
	
	public String execute() throws Exception{
		
		paramClass = new noticeBoardVO(); 
		resultClass = new noticeBoardVO();
		
		paramClass.setSubject(getSubject()); 
		paramClass.setPassword(getPassword());
		paramClass.setContent(getContent()); 
		paramClass.setRegdate(today.getTime()); 
		
		sqlMapper.insert("notice.insertBoard", paramClass);
		
		return SUCCESS; 
		
	}
	
	
	
	
	
	public noticeBoardVO getParamClass() {
		return paramClass;
	}
	public void setParamClass(noticeBoardVO paramClass) {
		this.paramClass = paramClass;
	}
	public noticeBoardVO getResultClass() {
		return resultClass;
	}
	public void setResultClass(noticeBoardVO resultClass) {
		this.resultClass = resultClass;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getNo() {
		return no;
	}
	public void setNo(int no) {
		this.no = no;
	}
	public String getSubject() {
		return subject;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public Calendar getToday() {
		return today;
	}
	public void setToday(Calendar today) {
		this.today = today;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Map getSession() {
		return session;
	}

	public void setSession(Map session) {
		this.session = session;
	}

	public int getBoardFlag() {
		return BoardFlag;
	}

	public void setBoardFlag(int boardFlag) {
		BoardFlag = boardFlag;
	} 
	
	

}
